package com.sinopec.scandevice.api;

import com.sinopec.basemodule.http.HttpParam;
import com.sinopec.basemodule.http.api.AppService;
import com.sinopec.basemodule.http.api.HttpResult;
import com.sinopec.basemodule.http.api.LoginService;
import com.sinopec.basemodule.http.api.RetroAPIFactory;
import com.sinopec.basemodule.model.login_model.UserInfo;

import java.util.HashMap;

import io.reactivex.Observable;

/**
 * Created by ronny on 2018/3/27.
 */

public class LoginApi {
    static {
        mLoginApi = new LoginApi();
    }

    private static LoginApi mLoginApi;
    private final LoginService mineService;
    private final AppService apiService;

    public LoginApi() {
        apiService = RetroAPIFactory.create(AppService.class);
        mineService = RetroAPIFactory.create(LoginService.class);
    }

    public static LoginApi getInstance() {
        return mLoginApi;
    }


    public Observable<HttpResult<UserInfo>> login(String userPhone, String password, String deviceNo) {
        HashMap<String, String> paramMap = HttpParam.createParams(true)
                .putParam("userAccount", userPhone)
                .putParam("passWord", password)
                .putParam("equipmentCode", deviceNo)//设备号
                .end();
        return mineService.login(paramMap);
    }

}
